<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<pre>
    moment()

    1.不传入日期对象或字符串，使用当前时间
    2.可传入日期对象或日期字符串
    3.不调用 .format() 返回 moment 对象
    4.调用 .format() 返回 格式化日期字符串

</pre>
</body>
<script src="moment.js"></script>
<script>
    var now=new Date();
    var fstr='YYYY-MM-DD HH:mm:ss';

    //不传入参数，返回当前时间对象
    console.warn('日期对象');

    console.log( moment() );//moment对象

    console.log( moment(now).format() );//2016-11-24T10:18:17+08:00

    console.log( moment(now).format(fstr) );//2016-11-24 10:18:17


    var dstr='2016-11-24 10:06:21';
    console.warn('日期字符串');
    console.log( moment(dstr));//moment对象

    console.log( moment(dstr).format(fstr));//2016-11-24 10:18:17

    console.log( moment({y:2010,M:3,d:5,h:15,m:10,s:3,ms:123}) );//moment对象
    console.log( moment({y:2010,M:3,d:5,h:15,m:10,s:3,ms:123}).format() );//2016-11-24T10:18:17+08:00

    console.warn('fromNow:');
    console.log(moment(dstr).fromNow());
    console.log(moment(new Date()).fromNow());

</script>
</html>
